# Makefile include for branch specific configuration settings
#
# Copyright (C) 2020  Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Store a branch specific configuration here to avoid dealing with
# conflicts on multiple places.

CONTAINER_REGISTRY = quay.io
CI_TAG ?= {$ distro_name $}-{$ distro_release $}

# Parse CI_TAG into distro and version (e.g., "fedora-41" or "rhel-9")
CI_TAG_DISTRO := $(word 1,$(subst -, ,$(CI_TAG)))
CI_TAG_VERSION := $(word 2,$(subst -, ,$(CI_TAG)))

# Compute BASE_CONTAINER based on CI_TAG
BASE_CONTAINER = $(strip \
  $(if $(filter eln,$(CI_TAG_VERSION)), \
      $(CONTAINER_REGISTRY)/fedora/$(CI_TAG_VERSION):latest-x86_64, \
      $(if $(filter fedora,$(CI_TAG_DISTRO)), \
          $(CONTAINER_REGISTRY)/fedora/$(CI_TAG_DISTRO):$(CI_TAG_VERSION), \
          $(if $(filter rhel,$(CI_TAG_DISTRO)), \
              $(CONTAINER_REGISTRY)/centos/centos:stream$(CI_TAG_VERSION), \
          ) \
      ) \
  ))

{% if distro_name == "fedora" and distro_release == "rawhide" %}

# Name of the expected current git branch.
# This could be main, fedora-XX, rhel-X ...
GIT_BRANCH ?= main

# Directory for this anaconda branch in anaconda-l10n repository. This could be main, fXX, rhel-8 etc.
L10N_DIR ?= main

# COPR repo for use in container builds.
COPR_REPO ?= \@rhinstaller/Anaconda

{% elif distro_name == "fedora" %}

GIT_BRANCH ?= fedora-{$ distro_release $}
L10N_DIR ?= f{$ distro_release $}

COPR_REPO ?= \@rhinstaller/Anaconda

{% elif distro_name == "rhel" and distro_release != 10 %}

GIT_BRANCH ?= rhel-{$ distro_release $}
L10N_DIR ?= rhel-{$ distro_release $}

COPR_REPO ?= rhinstaller-group/Anaconda

{% elif distro_name == "rhel" and distro_release == 10 %}

GIT_BRANCH ?= rhel-{$ distro_release $}
L10N_DIR ?= rhel-{$ distro_release $}

COPR_REPO ?= rhinstaller-group/Anaconda

{% endif %}
